package com.lp;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
//@ConditionalOnProperty(prefix = "swagger",value = {"enable"},havingValue = "true")
@EnableSwagger2
public class Swagger2 {



    public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.lp.*.controller";
    public static final String VERSION = "1.0.0";

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("奔云接口")
                .description("请求参数<br>" +
                        "os：操作系统1.pc 2.安卓3.ios" +
                        "<br>channel:1.浏览器2.原生"+
                        "<br>vendor:设备生产商"+
                        "<br>model:型号"+
                        "<br>browser:浏览器信息<BR>"+
                        "<br>应该返回的结果<br>{data: 具体的数据,errorCode: 1000未登录错误1001参数错误1002系统异常,errorStr: 错误信息,sessionId: \"string\",success: 是否成功1.成功0.失败" +
                        "}" +
                        "<br>nextPage：下一个页\n" +
                        "previousPage:上一页\n" +
                        "count：总条数\n" +
                        "pageTotal:总页数\n" +
                        "end：1没有下一页0.还有下一页\n" +
                        "dataCount当前页的记录数")
                //.license("Apache 2.0")
               // .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
                .termsOfServiceUrl("")
                .version(VERSION)
                //.contact(new Contact("","", "miaorf@outlook.com"))
                .build();
    }
    @Bean
    public Docket createRestApi() {
    	return new Docket(DocumentationType.SWAGGER_2)
    	.apiInfo(apiInfo())
    	.select()
    	.apis(RequestHandlerSelectors
    	.withMethodAnnotation(ApiOperation.class))
    	.paths(PathSelectors.any()).build();
    	}
}